package com.qianfeng.smartmeeting.config;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.time.LocalDate;

@Component
public class MyMetaObjectHandler implements MetaObjectHandler {
    @Override
    public void insertFill(MetaObject metaObject) {
        int year = LocalDate.now().getYear();
        this.strictInsertFill(
                metaObject,
                "useYear",
                Integer.class,
                year
        );

        int month = LocalDate.now().getMonthValue();
        this.strictInsertFill(
                metaObject,
                "useMonth",
                Integer.class,
                month
        );

        int day = LocalDate.now().getDayOfMonth();
        this.strictInsertFill(
                metaObject,
                "useDay",
                Integer.class,
                day
        );
    }

    @Override
    public void updateFill(MetaObject metaObject) {

    }
}
